/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2012/11/19
* File: EnnMovableObject.h
**/

#ifndef EnnMovableObject_h__
#define EnnMovableObject_h__

#include "EnnPrerequisites.h"
#include "EnnAxisAlignedBox.h"
#include "EnnSphere.h"

namespace Enn
{
	class _EnnExport MovableObject : public MovableObjectAlloc
	{
	public:
		class _EnnExport Listener
		{
		public:
			Listener()
			{

			}

			virtual ~Listener() 
			{
		
			}

			/** MovableObject is being destroyed */
			virtual void objectDestroyed(MovableObject* mo)
			{

			}

			/** MovableObject has been attached to a node */
			virtual void objectAttached(MovableObject* mo)
			{

			}

			/** MovableObject has been detached from a node */
			virtual void objectDetached(MovableObject* mo)
			{

			}

			/** MovableObject has been moved */
			virtual void objectMoved(MovableObject* mo)
			{

			}
		};

	public:
		MovableObject(const String& name);
		virtual ~MovableObject();

		virtual const String& getName() const
		{
			return _name;
		}

		virtual SceneNode* getParent() const
		{
			return _parent;
		}

		virtual const AxisAlignedBox& getBoundingBox() const
		{
			return _local_aabb;
		}

		virtual const Sphere& getBoundingSphere() const
		{
			return _local_sphere;
		}

		virtual Real getBoundingRadius() const
		{
			return _local_sphere.getRadius();
		}

		virtual const AxisAlignedBox& getWorldBoundingBox() const
		{
			return _local_aabb;
		}

		virtual const Sphere& getWorldBoundingSphere() const
		{
			return _local_sphere;
		}

		virtual void setVisible(bool visible)
		{
			_visible = visible;
		}

		virtual bool isVisible() const
		{
			return _visible;
		}

		virtual void setListener(Listener* listener)
		{
			_listener = listener;
		}

		virtual Listener* getListener() const
		{
			return _listener;
		}

	protected:
		String			_name;
		SceneNode*		_parent;
		Listener*		_listener;
		bool			_visible;
		AxisAlignedBox	_local_aabb;
		Sphere			_local_sphere;
	};
}

#endif    /* EnnMovableObject_h__ */